"""
行为树黑板 - 命名空间:
    命名空间允许您将黑板上的键分组到逻辑上相关的组中，以便于管理和避免键名冲突
"""

import py_trees

if __name__ == "__main__":
    blackboard = py_trees.blackboard.Client(name="Global")
    parameters = py_trees.blackboard.Client(name="Parameters", namespace="parameters")

    blackboard.register_key(key="foo", access=py_trees.common.Access.WRITE)
    blackboard.register_key(key="/bar", access=py_trees.common.Access.WRITE)
    blackboard.register_key(key="/parameters/default_speed", access=py_trees.common.Access.WRITE)
    parameters.register_key(key="aggressive_speed", access=py_trees.common.Access.WRITE)

    blackboard.foo = "foo"
    blackboard.bar = "bar"
    blackboard.parameters.default_speed = 20.0
    parameters.aggressive_speed = 60.0

    miss_daisy = blackboard.parameters.default_speed
    van_diesel = parameters.aggressive_speed

    print(blackboard)
    print(parameters)

""" 
Blackboard Client
  Client Data
    namespace         : /
    exclusive         : set()
    unique_identifier : 4d64dfde-3a69-4f3d-b31a-629fc7ca84a6
    write             : {'/parameters/default_speed', '/bar', '/foo'}
    name              : Global
    read              : set()
  Variables
    /foo                      : foo
    /bar                      : bar
    /parameters/default_speed : 20.0


Blackboard Client
  Client Data
    namespace         : /parameters
    exclusive         : set()
    unique_identifier : e9777175-0f3f-45af-af03-209ab16fb6c3
    write             : {'/parameters/aggressive_speed'}
    name              : Parameters
    read              : set()
  Variables
    /parameters/aggressive_speed : 60.0
"""